home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / programr / wtj008.zip / OBJECTS.ZIP / TSTRINGS.PAS < prev    next >
Pascal/Delphi Source File  |  1992-05-17  |  1KB  |  44 lines

  1. {$S-,R-}
  2. Library TStrings;
  3. uses WinTypes, Strings;
  4.  
  5. type
  6.   PString = ^TString;
  7.   TString =
  8.     record
  9.       sString : PChar;
  10.       sGetString : function(sSelf : PString) : PChar;
  11.       sDone : procedure (sSelf : PString);
  12.     end;
  13.  
  14. function TStringsGetString(sSelf : PString) : PChar; Export;
  15. begin
  16.   TStringsGetString := sSelf^.sString;
  17. end;
  18.  
  19. procedure TStringsDone(sSelf : PString); Export;
  20. begin
  21.   with sSelf^ do
  22.     FreeMem(sString, StrLen(sString) + 1);
  23. end;
  24.  
  25. function TStringInit(AString : PChar; var sSelf : TString) : Bool; Export;
  26.   {-Initialize an instance of a TString.}
  27. begin
  28.   with sSelf do begin
  29.     GetMem(sString, StrLen(AString) + 1); {get memory for our string}
  30.     StrCopy(sString, AString);            {init the sString field}
  31.     sGetString := TStringsGetString;      {set the "virtual methods"}
  32.     sDone := TStringsDone;
  33.     TStringInit := sString <> Nil; {return TRUE if GetMem succeeded}
  34.   end;
  35. end;
  36.  
  37. Exports
  38.   TStringInit                index 1,
  39.   TStringsGetString          index 2,
  40.   TStringsDone               index 3;
  41.  
  42. begin
  43. end.
  44.